﻿using System;
using System.Collections.Generic;
using Communication.Message;

namespace Communication.Channel.Serial
{
	// Token: 0x0200002E RID: 46
	internal class MessageQueue : Queue<ChannelMessage>
	{
		// Token: 0x06000168 RID: 360 RVA: 0x00004E7C File Offset: 0x0000307C
		public MessageQueue(int maxCount) : base(maxCount)
		{
			this.maxCount = maxCount;
		}

		// Token: 0x06000169 RID: 361 RVA: 0x00004E8C File Offset: 0x0000308C
		public new ChannelMessage Dequeue()
		{
			ChannelMessage result;
			lock (this)
			{
				if (this.Count > 0)
				{
					result = base.Dequeue();
				}
				else
				{
					result = null;
				}
			}
			return result;
		}

		// Token: 0x0600016A RID: 362 RVA: 0x00004ED0 File Offset: 0x000030D0
		public new void Enqueue(ChannelMessage item)
		{
			lock (this)
			{
				if (this.Count >= this.maxCount)
				{
					throw new MessageQueueFullException();
				}
				base.Enqueue(item);
			}
		}

		// Token: 0x17000008 RID: 8
		// (get) Token: 0x0600016B RID: 363 RVA: 0x00004F1C File Offset: 0x0000311C
		public new int Count
		{
			get
			{
				int count;
				lock (this)
				{
					count = base.Count;
				}
				return count;
			}
		}

		// Token: 0x0600016C RID: 364 RVA: 0x00004F54 File Offset: 0x00003154
		public new void Clear()
		{
			lock (this)
			{
				base.Clear();
			}
		}

		// Token: 0x0400005C RID: 92
		private int maxCount;
	}
}
